#include<cstdio>
using namespace std;
int main()
{
	int m, n, max = 1;
	scanf("%d %d", &m, &n);
	for (int i = 1, len = m > n ? n : m; i <= len; i++)
	{
		if (m % i == 0 && n % i == 0)
		{
			max = i;
		}
	}
	printf("%d", max);
	return 0;
}
